<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.kaishengit.entity.User" %>
<%@ page import="com.kaishengit.entity.Project" %>
<%@ page import="com.kaishengit.entity.Goal" %>
<!DOCTYPE HTML>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title></title>
	
	
	<link rel="stylesheet" href="css/bootstrap.min.css" />
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	
	<style type="text/css">
		a:hover{
			text-decoration:none;
		}
	</style>
	
	
</head>
<body>


	
	
	
	
		<div class="navbar">
		<div class="navbar-inner">
			<div class="container">
				 
				<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
				<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</a>
				 
				<!-- Be sure to leave the brand out there if you want it shown -->
				<a class="brand" href="#">欢迎使用PM系统</a>
				<ul class="nav" >
					<li style="margin-left:40px;">
						<a href="personmanager.jspx">成员管理</a>
					</li>
					<li><a href="newproject.jspx" style="margin-left:40px;">新建项目</a></li>
					<li><a href="projectlistview.jspx" style="margin-left:40px;">项目列表</a></li>
					<li><a href="#" style="margin-left:40px;">我的任务</a></li>
					<li><a href="#" style="margin-left:40px;">附加功能</a></li>
				</ul>
				 
				<!-- Everything you want hidden at 940px or less, place within here -->
				<ul class="nav pull-right">
					<li>
						<a href="#">欢迎您：</a>
					</li>
					<li class="divider-vertical"></li>
					<li style="margin-top:10px;"><%=((User)session.getAttribute("session_user")).getUsername() %> </li>
				</ul>
			</div>
		</div>
    </div>
	
	
	
	

	
		<form id="newtask" class="well" action="newtaskadd.jspx" method="post" style="margin-left:200px;width:800px;" >
		
		
			<%
			String state = (String)request.getAttribute("state");
			String msg = "";
			if("10002".equals(state)) {
				msg = "添加任务成功";
			%>
			 <div id="msgerror" class="alert alert-error">
		    	<%=msg%>
		    </div>
			
			<%}else if("10001".equals(state)) {
				msg="该项目中任务已经存在";
			%>
			 <div id="msgerror" class="alert alert-error">
		    	<%=msg%>
		    </div>
			<%} %>
		
		
		    <ul class="breadcrumb">
				<li>
				<a href="#">添加任务</a>
				</li>
				
			</ul>
		
		<label>任务名称</label>
		<input id="taskname" type="text" class="span3"name="taskname">
		
		<label class="control-label" for="textarea">任务说明</label>
		<div class="controls">
		<textarea id="taskdesc" id="textarea" class="input-xlarge" rows="3" name="taskdesc"></textarea>
		</div>
		
		
		<label class="control-label">任务状态</label>
		<select class="span2" name="taskstate">
                <option>新任务</option>
                <option>进行中</option>
                <option>已完成</option>
        </select>
		<br/>
		
		
		<label class="control-label">任务级别</label>
		<select class="span2" name="tasktype">
                <option>重要不紧急</option>
                <option>重要紧急</option>
                <option>重要不紧急</option>
				<option>不重要不紧急</option>
        </select>
		
		
		<label class="control-label" >负责人</label>
		<select class="span2" name="taskmanager">
			<%
				List<User> listuser = (List<User>)request.getAttribute("listuser");
				for(User user : listuser) {
			
			%>
			<option><%=user.getUsername()%></option>
			
			<%} %>
                
        </select>
        
        
        <label class="control-label" >所属项目</label>
		<select class="span2" name="taskproject">
			<%
				List<Project> listproject = (List<Project>)request.getAttribute("listproject");
				String projectname = (String)request.getAttribute("projectname");
				for(Project project : listproject) {
					if(project.getName().equals(projectname)) {
			%>
			<option><%=project.getName()%></option>
			
			<%} }%>
                
        </select>
        
        
        <label class="control-label" >所属目标</label>
		<select class="span2" name="taskgoal">
			<%
				List<Goal> listgoal = (List<Goal>)request.getAttribute("listgoal");
				String goalname = (String)request.getAttribute("goalname");
				if(goalname.equals("")) {
					for(Goal goal : listgoal) {
			%>	
				
					<option><%=goal.getName()%></option>
			
			<%}}else {%>		
			<%
				for(Goal goal : listgoal) {
					if(goal.getName().equals(goalname)) {
			%>
				<option><%=goal.getName()%></option>
			
			<%}}} %>
                
        </select>
		
		<br/>
		
		
		<div id="msgcheck" class="alert alert-error"> 
	    </div>
		
		<button type="submit" class="btn btn-success">保存</button>
	</form>
	
	
	
	  

	
	<script type="text/javascript">
	
	var taskname = document.getElementById("taskname");
	var taskdesc = document.getElementById("taskdesc");
	
	var msgcheck = document.getElementById("msgcheck");
	var msgerror = document.getElementById("msgerror");
	
	msgcheck.style.display="none";
	
	
			document.getElementById("newtask").onsubmit=function() {
				if(taskname.value=="" || taskdesc.value=="") {
					msgcheck.style.display="block";
					msgcheck.innerHTML="不能为空";
					return false;
				}
			}
			taskname.onfocus = function() {
				msgcheck.style.display="none";
				if(msgerror!=null && msgerror.innerHTML!="")
					msgerror.style.display="none";
			
			}
			
			
			taskdesc.onfocus = function() {
				msgcheck.style.display="none";
				if(msgerror!=null && msgerror.innerHTML!="")
				msgerror.style.display="none";
				
			}
	</script>
	
</body>
</html>
